<?php
class msgAction extends Action {
	function index(){
		$user = D('msg');
		$count = $user->count();
		$pre_page = 5;
		$p=intval($_GET['p']);
		$p=$p==0 ? 1 : $p;
		$start=($p-1)*$pre_page;
		$list = $user->limit("$start,$pre_page")->findAll();
        
		import('ORG.Util.Page');
		$page = new Page($count,$pre_page);
		$pages = $page->myshow('/msg/');
		$this->assign('pages',$pages);
		
		$this->assign('list',$list);
		
		pubAction::get_slist();
		$this->display('default@msg');
	}
	
	function mpost(){
		$hid = intval($_POST['hid']);
		if($hid==1){
			$msg = addslashes($_POST['msg']);
			$user = D('msg');
			$arr['name'] = str_set($_POST['name']);
			$arr['name'] = $arr['name']=='' ? '网友' : $arr['name'];
			$arr['msg'] = str_set($_POST['msg']);
			$arr['send_time'] = time();
			
			$re= $user->add($arr);
			if($re){
				go('/msg','提交成功!',1);
			}
		}
	}
	
	
}
?>